package bigmath;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;

public class VectorDemo {
    /*
    向量 初始容量10 要扩容0若不指定每次默认增加一倍
     */
    public static void main(String[] args) {
        Vector<String> v = new Vector<>();
        //添加元素
        v.addElement("b");
        v.add("hh");
        v.add("e");

//        Enumeration<String> e = v.elements();
//        while (e.hasMoreElements()){
//            String s = e.nextElement();
//            System.out.println(s);
//        }
        //从JDK1.2开始，建议Iterator来代替
        Iterator<String> its = v.iterator();
        while (its.hasNext()){
            String s = its.next();
            System.out.println(s);
        }

        Iterator<String> it = v.iterator();
        //判断是否有下一个元素
        while(it.hasNext()){
            String s = it.next();
            System.out.println(s);
        }
        System.out.println(v);
    }
}
